﻿using System;

namespace Forex.Components
{
	public class TickInterval
	{
		public int TickIntervalID { get; private set; }

		public int TickerID { get; set; }

		public DateTime PeriodBegin { get; set; }

		public decimal OpenPrice { get; set; }

		public decimal ClosePrice { get; set; }

		public decimal HighPrice { get; set; }

		public decimal LowPrice { get; set; }

		public TickIntervalType IntervalType { get; private set; }

		public override string ToString()
		{
			return String.Format(
				"TickIntervalID={0}, TickerID={1}, PeriodBegin={2}, OpenPrice={3}, ClosePrice={4}, HighPrice={5}, LowPrice={6}",
				this.TickIntervalID,
				this.TickerID,
				this.PeriodBegin,
				this.OpenPrice,
				this.ClosePrice,
				this.HighPrice,
				this.LowPrice);
		}

		#region Persistent state

		public static TickIntervalList Retrieve(DateTime periodBegin, DateTime periodEnd)
		{
			return Data.FileDataFactory.Instance().CreateTickIntervalDate().Retrieve(periodBegin, periodEnd);
		}

		#endregion Persistent state
	}
}
